package com.controller;

import com.pojo.Student;
import com.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

@Controller
@RequestMapping(value = "/student")
public class StudentController {

    @Resource
    private StudentService studentService;

    @RequestMapping(value = "/fetchById")
    public ModelAndView fetchById(@RequestParam(value = "id") int id) {
        Student student = studentService.fetchById(id);
        ModelAndView mv = new ModelAndView();
        mv.setViewName("student_detail");
        mv.addObject("student", student);
        return mv;
    }

}
